package com.item.controller;


import com.item.domain.TbUserMail;
import com.item.service.TbUserMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TbUserMailController {

    @Autowired
    TbUserMailService tbUserMailService;

    @PostMapping(value = "/tbUserMail/{limit}/{page}")
    public List<TbUserMail> TbUserMail(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) TbUserMail tbUserMail) {
        List<TbUserMail> tbUserMails = tbUserMailService.findAll(limit, page, tbUserMail);

        return tbUserMails;
    }

    @PostMapping(value = "/tbUserMail/add")
    public Integer TbUserMailAdd(@RequestBody TbUserMail tbUserMail) {
        tbUserMail.setCreateTime(System.currentTimeMillis() + "");
        int i = tbUserMailService.add(tbUserMail);
        return i;
    }

    @PutMapping(value = "/tbUserMail/update")
    public Integer tbUserMailUpdate(@RequestBody TbUserMail tbUserMail) {

        int i = tbUserMailService.update(tbUserMail);
        return i;
    }

    @DeleteMapping(value = "/tbUserMail/{id}")
    public Integer tbUserMailDelete(@PathVariable(value = "id") int id) {

        int i = tbUserMailService.delete(id);
        return i;
    }

    @PostMapping(value = "/tbUserMail/getImage/{image}")
    public String tbUserMailGetImage(@PathVariable(value = "image") String image) {

        String imagess = image;
        System.out.println(image);
        return "";
    }

}
